cc.Class({
    extends: cc.Component,

    properties: {
        mBackGroup: cc.Sprite,
        mGameUI: cc.SpriteAtlas,
        mHeroPrefab: [cc.Prefab],
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    // update (dt) {},

    setHeroStyle: function (hero) {
        if(this.mHeroPrefab[hero.id] === null) {
            return;
        }
        const ins = cc.instantiate(this.mHeroPrefab[hero.id]);
        this.mBackGroup.node.addChild(ins);
    },

    setStyle: function (hero) {
        if(hero === null) {
            return;
        }
        cc.log('style of hero is ', hero.style);
        let frame;
        switch (hero.style) {
            case 0:
            // yellow background
                frame = this.mGameUI.getSpriteFrame('GameUI16');
                this.mBackGroup.spriteFrame = frame;
                this.mBackGroup.node.width = 104;
                this.mBackGroup.node.height = 310;
                break;
            case 1:
                // blue background
                frame = this.mGameUI.getSpriteFrame('GameUI17');
                this.mBackGroup.spriteFrame = frame;
                this.mBackGroup.node.width = 104;
                this.mBackGroup.node.height = 310;
                break;
            default:
                frame = this.mGameUI.getSpriteFrame('GameUI17');
                this.mBackGroup.spriteFrame = frame;
                this.mBackGroup.node.width = 104;
                this.mBackGroup.node.height = 310;
                break;
        }
        this.setHeroStyle(hero);
    }
});
